

var chromeUtils = {
	getRootPath : function (){
	    //获取当前网址，如： http://localhost:8083/uimcardprj/share/meun.jsp
	    var curWwwPath=window.document.location.href;
	    //获取主机地址之后的目录，如： uimcardprj/share/meun.jsp
	    var pathName=window.document.location.pathname;
	    var pos=curWwwPath.indexOf(pathName);
	    //获取主机地址，如： http://localhost:8083
	    var localhostPaht=curWwwPath.substring(0,pos);
	    //获取带"/"的项目名，如：/uimcardprj
	    var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
	    return(localhostPaht+projectName);
	},
	
	getUrl : function(){
		return window.document.location.href;
	},
	getUrlParams : function(url){
		if(!url)return null;
		if(url.indexOf("?") < 0)return null;
		var urlarray = url.split("?");
		var paramStr = urlarray[urlarray.length-1];
		var keyValueStrArray = paramStr.split("&");
		if(!keyValueStrArray || keyValueStrArray.length < 1)return null;
		var urlParamObj = {};
		var dataCount = 0;
		for(var i=0; i < keyValueStrArray.length; i++){
			var keyValueStr = keyValueStrArray[i];
			var keyValueArray = keyValueStr.split("=");
			if(!keyValueArray)continue;
			if(keyValueArray.length == 2){
				urlParamObj[keyValueArray[0]] = keyValueArray[1];
				dataCount ++ ;
			}else if(keyValueArray.length == 1){
				urlParamObj[keyValueArray[0]] = null;
				dataCount ++;
			}
		}
		if(dataCount < 1)return null;
		return urlParamObj;
	},
	getYuming :function (url){
		if(!url)return url;
		var yuming = url.replace("https://","").replace("http://","");
		var gengind = yuming.indexOf("/");
		yuming = yuming.substring(0,gengind > -1 ? gengind : yuming.length );
		return yuming;
	},
	/**
	 * 是否是正整数
	 * @param {Object} d
	 */
	isNumber : function(d){
		var reg = /^[0-9]+$/;
		return reg.test(d);
	}
	,getUrlF : function(url){
		var res = {};
		var gengind = url.lastIndexOf("/");
		if(gengind < 0 || gengind == url.length-1){
			return res;
		}
		gengind += 1;
	    var u1 = url.substring(0, gengind);
	    var u2 = url.substring(gengind,url.length);
	    res.u1 = u1;
	    res.u2 = u2;
	    return res;
	}
}
